package com.neiru.divider.facade;

import android.content.Context;

import com.neiru.divider.bean.Player;
import com.neiru.divider.dao.PlayerDao;

public class PlayerFacade {
	private PlayerDao playerDao;
	public PlayerFacade(Context context) {
		this.playerDao = new PlayerDao(context);
	}
	public void updatePlayer(Player player) {
		this.playerDao.open();
		this.playerDao.updatePlayer(player);
		this.playerDao.close();
	}
	public Player getPlayer() {
		this.playerDao.open();
		Player player = this.playerDao.getPlayer();
		if(player == null) {
			player = new Player();
			player.setLastLevel(1);
			player.setScore(0);
			this.playerDao.createPlayer(player);
		}
		this.playerDao.close();
		return player;
	}
}
